package com.hyh.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import android.view.WindowManager;

import com.hyh.service.CoreService;
import com.hyh.ui.keepalive.KeepAliveActivity;
import com.hyh.util.CheckHomeUtil;
import com.hyh.util.SoundUtil;

/**
 * Created by Administrator on 2019/2/26.
 */

public class SceenReceiver extends BroadcastReceiver {

    private Context context;
    Handler handler = new Handler();
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if(CheckHomeUtil.isAtHome(context)){
                SoundUtil.getInstance(context).play();
            }
            handler.postDelayed(this,1000);
        }
    };
    @Override
    public void onReceive(Context context, Intent intent) {
        this.context = context;
        switch (intent.getAction()){
            case Intent.ACTION_SCREEN_OFF:
//                handler.removeCallbacks(runnable);
//                Intent intent1 = new Intent(context, KeepAliveActivity.class);
//                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                context.startActivity(intent1);
                break;
            case Intent.ACTION_SCREEN_ON:
//                handler.post(runnable);
                break;
        }

    }
}
